package wework

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

func getWeworkUser(corpId string, secret string, userId string) string {
	token, err := GetAccessToken(corpId, secret)
	if err != nil {
		return ""
	}
	url := fmt.Sprintf("%s/user/get?access_token=%s&userid=%s", WEWORK_HOST, token, userId)
	resp, err := http.Get(url)
	if err != nil {
		log.Printf("GetAccessToken error. %v", err.Error())
		return ""
	}
	defer resp.Body.Close()
	log.Printf("status code is %d", resp.StatusCode)
	bytes, err := ioutil.ReadAll(resp.Body)
	content := string(bytes)
	return content
}
